/**
 * 验证URL
 * @param {string} url
 * @returns {Boolean}
 */
const validURL = (url) => {
    const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
    return reg.test(url)
}

/**
 * 获取URL地址中的参数
 * @param url
 * @returns {null}
 */
const serilizeURL = (url) => {
    let urlObject = {}
    if (/\?/.test(url)){
        let urlString = url.substring(url.indexOf("?")+1)
        let urlArray = urlString.split("&")
        for (let i = 0,len = urlArray.length; i < len; i++) {
            let urlItem = urlArray[i]
            var item = urlItem.split("=")
            urlObject[item[0]] = item[1]
        }
        return urlObject
    }
    return null
}
